<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>kylin-frame</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="icon" href="images/favicon.ico" type="image/x-icon"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="css/admin.css" media="all"/>
    <link rel="stylesheet" href="css/login.css" media="all"/>
    <script src="plugins/layui/layui.js"></script>
    <script src="scripts/basic.js"></script>
</head>
<body class="loginBody">
<form class="layui-form">
    <div class="layui-form-item">
        <h1 style="text-align: center;margin: 10px 15%">kylin-frame</h1>
    </div>
    <div class="layui-form-item mgb25">
        <input type="text" placeholder="请输入用户名" autocomplete="off" name="username" id="username" class="layui-input"
               lay-verify="required">
    </div>
    <div class="layui-form-item mgb25">
        <input type="password" placeholder="请输入密码" autocomplete="off" name="password" id="password" class="layui-input"
               lay-verify="required">
    </div>
    <div class="layui-form-item mgb25" id="imgCode">
        <input type="text" placeholder="请输入验证码" autocomplete="off" name="captcha" id="captcha" class="layui-input"
               lay-verify="required">
        <img src="/kylin-frame/captcha.jpg" id="captchaImg"
             onclick="this.src='/kylin-frame/captcha.jpg?'+Math.random();">
    </div>
    <div class="layui-form-item">
        <button class="layui-btn login-btn" lay-filter="login" lay-submit>登录</button>
    </div>
    <div class="layui-form-item">
        <p style="color: #333;text-align: center;">测试账号：admin 密码：admin</p>
    </div>
</form>
</body>
<script>

    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form, layer = parent.layer === undefined ? layui.layer
            : top.layer, $ = layui.jquery;
        // 登录按钮
        form.on("submit(login)", function (data) {
            // 弹出loading
            var index = top.layer.msg('登陆中...', {
                icon: 16,
                time: false,
                shade: 0.8
            });
            var params = data.field;
            $.post(baseURL + "sys/login", params, function (res) {
                layer.close(index);

                if (res.code == 1) {
                    layer.msg("登陆成功", {
                        icon: 6,
                        time: 500
                    });
                    setTimeout(function () {
                        window.location.href = "index.html";
                    }, 1000);
                    localStorage.setItem("token", res.data.token);
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 1000
                    });
                    refreshCode();
                }
            });
            return false;
        });
    });

    function refreshCode() {
        document.getElementById("captchaImg").src = baseURL + "captcha.jpg?" + Math.random();
    }
</script>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?a78f30a9467b7d12a67f156d272b5e4e";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>

</html>